﻿using System;
using System.Collections.Generic;
using System.Text;

using E.Model;
using E.DAL;

namespace E.BLL
{
    public class PublicCourseBLL
    {
        private PublicCourseDAL dal;

        public PublicCourseBLL()
        {
            dal = new PublicCourseDAL();
        }

        /// <summary>
        /// 添加公共课程
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddPublicCourse(PublicCourseModel model)
        {
            return dal.AddPublicCourse(model);
        }

        /// <summary>
        /// 获取简单公共课程列表
        /// </summary>
        /// <returns></returns>
        public IDictionary<int, string> GetSimplePublicCourseList()
        {
            return dal.GetSimplePublicCourseList();
        }

        /// <summary>
        /// 获取简单公共课程列表（非原有课程）
        /// </summary>
        /// <returns></returns>
        public IDictionary<int, string> GetSimpleNonOriginalPublicCourseList()
        {
            return dal.GetSimpleNonOriginalPublicCourseList();
        }

        /// <summary>
        /// 获取公共课程列表
        /// </summary>
        /// <returns></returns>
        public IList<PublicCourseModel> GetPublicCourseList()
        {
            return dal.GetPublicCourseList();
        }

        /// <summary>
        /// 检查课程名称是否重复
        /// </summary>
        /// <param name="coursename"></param>
        /// <param name="selfid"></param>
        /// <returns></returns>
        public bool CheckExistCourseName(string name, int selfid)
        {
            return dal.CheckExistCourseName(name, selfid);
        }

        /// <summary>
        /// 获取公共课程名称
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public PublicCourseModel GetPublicCourseInfoById(int id)
        {
            return dal.GetPublicCourseInfoById(id);
        }

        /// <summary>
        /// 更新公共课程
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdatePublicCourse(PublicCourseModel model)
        {
            return dal.UpdatePublicCourse(model);
        }

        /// <summary>
        /// 获取公共课程学员列表
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public PublicUserInCourseListModel GetUserInCourseListByCondition(PublicUserInCourseSearchModel searchModel, int pageSize, int pageIndex)
        {
            return dal.GetUserInCourseListByCondition(searchModel, pageSize, pageIndex);
        }

        /// <summary>
        /// 公共课程报名
        /// </summary>
        /// <param name="courseid"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public int SignUp(int courseid, int userid)
        {
            return dal.SignUp(courseid, userid);
        }

        /// <summary>
        /// 获取我的公共课程列表
        /// </summary>
        /// <returns></returns>
        public IList<PublicStudyLogModel> GetMyPublicCourseList(int userid)
        { 
            return dal.GetMyPublicCourseList(userid);
        }

        #region 公共课程课件

        /// <summary>
        /// 获取课件信息
        /// </summary>
        /// <param name="courseWareId"></param>
        /// <returns></returns>
        public PublicCourseWareModel GetPublicCourseWareInfoById(int courseWareId)
        {
            return dal.GetPublicCourseWareInfoById(courseWareId);
        }

        /// <summary>
        /// 获取课件信息（列表）
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IList<PublicCourseWareModel> GetPublicCourseWareInfoById(string[] id)
        {
            return dal.GetPublicCourseWareInfoById(id);
        }

        /// <summary>
        /// 添加课件
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddPublicCourseWare(PublicCourseWareModel model)
        {
            return dal.AddPublicCourseWare(model);
        }

        /// <summary>
        /// 更新课件
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdatePublicCourseWare(PublicCourseWareModel model)
        {
            return dal.UpdatePublicCourseWare(model);
        }

        /// <summary>
        /// 获取课件列表
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public PublicCourseWareListModel GetPublicCourseWareListByCondition(PublicCourseWareSearchModel searchModel, int pageSize, int pageIndex)
        {
            return dal.GetPublicCourseWareListByCondition(searchModel, pageSize, pageIndex);
        }

        /// <summary>
        /// 获取课件列表
        /// </summary>
        /// <param name="courseid"></param>
        /// <returns></returns>
        public IList<PublicCourseWareModel> GetPublicCourseWareListByCourseID(int courseid)
        {
            return dal.GetPublicCourseWareListByCourseID(courseid);
        }

        /// <summary>
        /// 删除课件
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DelPublicCourseWare(int id)
        {
            return dal.DelPublicCourseWare(id);
        }

        /// <summary>
        /// 更新页码（删除某一页时）
        /// </summary>
        /// <param name="startNumber"></param>
        /// <param name="courseid"></param>
        /// <returns></returns>
        public int UpdateSerialNumber(int startNumber, int courseid)
        {
            return dal.UpdateSerialNumber(startNumber, courseid);
        }

        #endregion
    }
}
